package com.tianji.remark.controller;


import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.websocket.server.PathParam;
import java.util.List;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author hc
 * @since 2024-08-26
 */
@Api(tags = "点赞和取消点赞相关接口")
@RestController
@RequestMapping("/likes")
public class LikedRecordController {

    @Autowired
    private ILikedRecordService likedRecordService;

    /**
     *  添加或取消点赞
     * @param likeRecordFormDTO 点赞数据
     */
    @PostMapping
    @ApiOperation("添加或取消点赞")
    public void addOrCancelLiked(@Valid @RequestBody LikeRecordFormDTO likeRecordFormDTO){
        likedRecordService.addOrCancelLiked(likeRecordFormDTO);
    }


    //TODO 改造查询回复接口
    /**
     *  查询当前用户是否点赞了指定的业务
     * @param bizIds 业务id
     * @return 当前用户点赞过的业务id
     */
    @GetMapping("list")
    @ApiOperation("批量查询点赞状态")
    public List<Long> queryIsLikedBizIds(@RequestParam("bizIds") List<Long> bizIds){
        return likedRecordService.queryIsLikedBizIds(bizIds);
    }
}
